﻿@model ProductModel

<script type="text/javascript">
    $(document).ready(function () {

        $("#@Html.FieldIdFor(model => model.LimitedToStores)").click(toggleStoreMapping);

            toggleStoreMapping();
        });


        function toggleStoreMapping() {
            if ($('#@Html.FieldIdFor(model => model.LimitedToStores)').is(':checked')) {
                $('#pnl-available-stores').show();
            }
            else {
                $('#pnl-available-stores').hide();
            }
        }

</script>
<table class="adminContent">
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.LimitedToStores):
        </td>
        <td class="adminData">
            @Html.EditorFor(model => model.LimitedToStores)
            @Html.ValidationMessageFor(model => model.LimitedToStores)
        </td>
    </tr>
    <tr id="pnl-available-stores">
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.AvailableStores):
        </td>
        <td class="adminData">
            @if (Model.AvailableStores != null && Model.AvailableStores.Count > 0)
            {
                foreach (var store in Model.AvailableStores)
                {
                <div>
                    <input type="checkbox" name="SelectedStoreIds" value="@store.Id" checked="@(Model.SelectedStoreIds != null && Model.SelectedStoreIds.Contains(store.Id))" />@store.Name
                </div>
                }
            }
            else
            {
                <div>No stores defined</div>
            }</td>
    </tr>
</table>
